const tools = (function(){
    const getStyle = (obj,attr) => {
        let res;
        if(window.getComputedStyle){
            res = window.getComputedStyle(obj,null)[attr];
        }else{
            res = obj.currentStyle[attr];
        }
        return parseInt(res);
    }

    const offset = (o) => {
        let res = {
            left:o.offsetLeft,top:o.offsetTop
        }
        while (o.offsetParent) {
            o = o.offsetParent;
            res.left = o.offsetLeft;
            res.top = o.offsetTop;
        }
        return res;
    }

    /* 暴露方法 */
    return{
        getStyle,
        offset
    }
})()